<template>
	<view >
		<uni-popup ref="popup"  type="bottom"  @change="popChange">
			<view class="pop-view">
				<view class="pop-close-view" @click="closePop">
					<text class="pop-close-txt">您的可用余额为：{{getNumber(dataCash)}}</text>
					<image class="pop-close-icon" src="../../static/pop-close-gray.png"></image>
				</view>
				<view class="pop-dikou-view" style="margin-top: 30px;" @click="lebalSelectDiKou">
					<text class="pop-dikou-txt">使用余额抵扣</text>
					<text class="pop-dikou-num">{{getNumber(dataDiKou)}}</text>
					<image class="pop-dikou-icon" :src="type==1?'../../static/icon-complete-info-select.png'
					:'../../static/icon-complete-info-unselect.png'"></image>
				</view>
				<view class="pop-dikou-view" @click="lebalSelectNoDiKou">
					<text class="pop-dikou-txt" style="flex: 1;margin-top: 0px;">暂不使用</text>
					<image class="pop-dikou-icon" :src="type==0?'../../static/icon-complete-info-select.png'
					:'../../static/icon-complete-info-unselect.png'"></image>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		name: "goods-buy-dikou-pop",
		props: {
			isShow:false,
			dataCash:Number,
			dataDiKou:Number,
			typeDiKou:Number,
		},
		watch: {
			isShow(val) {
				if(val){
					this.$refs.popup.open()
					this.type=this.$props.typeDiKou
				}
			}
		},
		data() {
			return {
				type:1,
				payPrice:0.00,
			};
		},
		methods:{
			getNumber: function(data){
				return parseFloat(data).toFixed(2);
			},
			lebalSelectDiKou:function(){
				this.type=1
				this.diKouClick()
			},
			lebalSelectNoDiKou:function(){
				this.type=0
				this.diKouClick()
			},
			popChange:function(e) {
				if(!e.show){
					var obj = {
						isclose: false,
					};
					this.$emit('returnGoodsBuyDiKouPop', obj);
				}
			},
			closePop:function(){
				this.$refs.popup.close();
			},
			diKouClick:function(){
				var obj = {
					isclose: false,
					type:this.type,
					tag:"123"
				};
				this.$emit('returnGoodsBuyDiKouPop', obj);
				this.$refs.popup.close();
			}
		}
	}
</script>

<style>
	@import "goods-buy-dikou-pop.css";
</style>
